package Model;

/**
 * Created by IntelliJ IDEA.
 * User: Andrew
 * Date: 09.03.12
 * Time: 17:47
 * To change this template use File | Settings | File Templates.
 */
public class LinearFilter {
    private int id;
    private String name;
    private int size;
    private float[] data;
    private float div;

    public LinearFilter(LinearFilter filter) {
        this.name = new String(filter.name);
        this.size = filter.size;
        this.data = filter.data.clone();
        this.div = filter.div;
    }
    
     //needed for serialization/deserialization
    public LinearFilter(){}

    public LinearFilter(String name, int size, float[] data, float div) {
        this.name = name;
        this.size = size;
        if (data == null) {
            this.data = new float[size * size];
            for (int i = 0; i < size; ++i)
                for (int j = 0; j < size; ++j)
                    if (i != size / 2 || j != size / 2)
                        this.data[i * size + j] = 0.0f;
                    else
                        this.data[i * size + j] = 1.0f;
        }
        else
          this.data = data;
        this.div = div;
    }

    @Override
    public String toString() {
        return name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public float[] getData() {
        return data;
    }

    public void setData(float[] data) {
        this.data = data;
    }

    public float getDiv() {
        return div;
    }

    public void setDiv(float div) {
        this.div = div;
    }
}
